import SourceEncoding,info
from infoTheory.ChannalEncoding import ChannelEncoding

inf=info.Info()
# inf.printList()
encode=SourceEncoding.SourceEncoding(inf.sourceList)



DemoList=[0.2,0.19,0.18,0.17,0.15,0.10,0.01]
encode.NewList(DemoList)
print("Huffman encoding as follows:")
encode.printEncodedList(encode.afterEncodingHuffmanList)
print("And it's efficiency is :")
print(str(encode.Efficiency(encode.afterEncodingHuffmanList)))


print("Fano encoding as follows:")
encode.printEncodedList(encode.afterEncodingFanoList)
print("And it's efficiency is :")
print(str(encode.Efficiency(encode.afterEncodingFanoList)))


print("Shannon encoding as follows:")
encode.printEncodedList(encode.afterEncodingShannonList)
print("And it's efficiency is :")
print(str(encode.Efficiency(encode.afterEncodingShannonList)))


print('\n')
cirList = ChannelEncoding([0, 1, 1, 0])
print("输入为",cirList.inputList)
print("循环码为:",cirList.circleList)
print("卷积码为:",cirList.convolution)
print("汉明码为:",cirList.humming)
cirList.circleCheck()
cirList.HanmmingCheck()
#
#
conList = ChannelEncoding([1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1])
print("输入为",conList.inputList)
print("循环码为:",conList.circleList)
print("卷积码为:",conList.convolution)
print("汉明码为:",conList.humming)
conList.circleCheck()
conList.HanmmingCheck()

#
HummingList = ChannelEncoding([0, 1, 1, 0, 1, 0, 0, 1])
print("输入为",HummingList.inputList)
print("汉明码为:",HummingList.humming)
print("循环码为:",HummingList.circleList)
print("卷积码为:",HummingList.convolution)
HummingList.circleCheck()
HummingList.HanmmingCheck()